﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using SES.CMS.DO;
using SES.CMS.BL;

namespace SES.CMS.AdminCP.PageUC
{
    public partial class ucCartDetail : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["sID"] == null)
                    Response.Redirect("Default.aspx");
                else
                {
                    string id = Request.QueryString["sID"].ToString();
                    load(id);
                    GetCustomerInfo(id);
                }
            }
        }

        public void load(string id)
        {
            DataTable dt = new cmsGioHangBL().SelectBySession(id);
            if (dt.Rows.Count > 0)
            {
                GrChiTiet.DataSource = dt;
                GrChiTiet.DataBind();
            }
        }

        private void GetCustomerInfo(string SessionID)
        {
            DataTable dt = new cmsGioHangBL().GetCustomerInfo(SessionID);
            if (dt.Rows.Count > 0)
            {
                lblDonHangID.Text = dt.Rows[0]["DonHangID"].ToString();
                lblTenKhachHang.Text = dt.Rows[0]["ClientName"].ToString();
                lblSoDienThoai.Text = dt.Rows[0]["Phone"].ToString();
                lblDiaChi.Text= dt.Rows[0]["Address"].ToString();
                lblEmail.Text= dt.Rows[0]["Email"].ToString();
                lblHTTT.Text= dt.Rows[0]["HinhThucThanhToan"].ToString();
                lblTongTien.Text = string.Format("{0:#,###}", dt.Rows[0]["TongTien"]) + " VNĐ";
                lblDiaChiGiaoHang.Text= dt.Rows[0]["DiaChiGiaoHang"].ToString();
                lblGhiChu.Text= dt.Rows[0]["GhiChu"].ToString();
            }
        }
    }
}